# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgbase=nautilus
pkgname=(
  nautilus
  libnautilus-extension
  libnautilus-extension-docs
)
pkgver=44.1
pkgrel=2
pkgdesc="Default file manager for GNOME"
url="https://wiki.gnome.org/Apps/Files"
arch=(x86_64)
license=(GPL)
depends=(
  dconf
  gdk-pixbuf2
  gnome-autoar
  gnome-desktop-4
  gst-plugins-base-libs
  gvfs
  libadwaita
  libcloudproviders
  libgexiv2
  libportal-gtk4
  tracker3
)
makedepends=(
  appstream-glib
  gi-docgen
  git
  gobject-introspection
  meson
  tracker3-miners
)
checkdepends=(python-gobject)
_commit=a3fda22858ad6186ace1b22bc466e4087d67ca8e  # tags/44.1^0
source=(
  "git+https://gitlab.gnome.org/GNOME/nautilus.git#commit=$_commit"
  no-tracker-test.diff
)
b2sums=('SKIP'
        '079cd60e8f408cd145bc71c4c0edb9738719adcaccb24f110464ac9cd87f6b65cc9246563c809aec65f67e050dce6b5f09520e621c61cb83ca4b7f13917d57cf')

pkgver() {
  cd nautilus
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd nautilus

  # Tracker test broken in our containers because bubblewrap stopped working,
  # also see https://bugs.archlinux.org/task/78033
  git apply -3 ../no-tracker-test.diff
}

build() {
  local meson_options=(
    -D docs=true
    -D packagekit=false
  )

  arch-meson nautilus build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

package_nautilus() {
  depends+=(libnautilus-extension.so)
  optdepends=(
    'nautilus-sendto: Send files via mail extension'
    'tracker3-miners: Full text search and metadata-based renaming'
  )
  groups=(gnome)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"

  _pick libne usr/include
  _pick libne usr/lib/{girepository-1.0,libnautilus-extension*,pkgconfig}
  _pick libne usr/share/gir-1.0

  _pick ldocs usr/share/doc
}

package_libnautilus-extension() {
  pkgdesc="Extension interface for Nautilus"
  depends=(
    gcc-libs
    glib2
  )
  provides=(libnautilus-extension.so)

  mv libne/* "$pkgdir"
}

package_libnautilus-extension-docs() {
  pkgdesc="Extension interface for Nautilus (documentation)"
  depends=()

  mv ldocs/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
